package Common
{
	
	
	public class GameCommonAction
	{
		public var direct:int = 0;
		public var textureID:int = GameDefine.INVALIDID;
		public var id:int = 0;
		public var actionID:int = GameAction.STAND;
		public var index:int = 0;
		public var frame:int = 0;
		public var isOver:Boolean = false;
		
		public var owner:Object = null;
		
		public var directionLast:int = MapDirection.DIRECTCOUNT;
		
		public var delay:Number = GameAction.ACTIONDELAY;
		public var timeDelay:Number = 0;
		
		public var actionStop:Boolean = false;
		
		
		public function GameCommonAction()
		{
		}
		
		public function init( owner:Object ):void
		{
			this.owner = owner;
		}
		
		public function release():void
		{
			owner = null;
		}
		
		public function setID( id:int ):void
		{
			this.id = id;
			//ActionManager.instance.load( id );
		}
		
		public function setActionID( id:int, stop:Boolean ):void
		{
			actionStop = stop;
			
			actionID = id;
			
			frame = -1;
			isOver = false;
			
			delay = GameAction.COMMOMACTIONDELAY;
		}
		
		public function update( delay:Number ):void
		{
			if ( isOver ) 
			{
				return;
			}
			
			timeDelay += delay;
			
			if ( timeDelay > this.delay ) 
			{
				timeDelay = 0;
				
				ActionChange();
				RenderManager.redraw = true;
			}
		}
		
		public function ActionChange():void
		{
//			frame++;
//			textureID = ActionManager.instance.getTextureID( id , direct , actionID , frame );
//					
//			if ( textureID == GameDefine.INVALIDID ) 
//			{
//				if ( actionStop )
//				{
//					isOver = false;
//				}
//				else
//				{
//					frame = 0;
//					textureID = ActionManager.instance.getTextureID( id , direct , actionID , frame );
//				}
//				
//			}
			
		}
		
	}
}